package com.boot.security.server.controller.mffl.MfflCommunityBack;

import com.boot.security.server.dao.mffl.MfflCommunityDao;
import com.boot.security.server.utils.mffl.ReturnBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "地区")
@RestController
@RequestMapping("Communitys")
public class MfflCommunityBackController {

    @Autowired
    private MfflCommunityDao mfflCommunityDao;

    @ApiOperation("一级省市列表")
    @GetMapping("/Level")
    public ReturnBean Level() {
        return new ReturnBean("200", mfflCommunityDao.Level(), "成功");
    }

    @ApiOperation("二级市列表")
    @GetMapping("/Level2")
    public ReturnBean Leve2(@ApiParam(name = "code", value = "省级code", required = true) @RequestParam String code) {
        if (StringUtils.isEmpty(code)) {
            return new ReturnBean("201", "省级code ,不能为空");
        }
        return new ReturnBean("200", mfflCommunityDao.Leve2(code), "成功");
    }

    @ApiOperation("三级区列表")
    @GetMapping("/Level3")
    public ReturnBean Leve3(@ApiParam(name = "code", value = "市级code", required = true) @RequestParam String code) {
        if (StringUtils.isEmpty(code)) {
            return new ReturnBean("201", "市级code ,不能为空");
        }
        return new ReturnBean("200", mfflCommunityDao.Leve3(code), "成功");
    }

}
